import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

    public class Test {
        public static void main(String[] args) {
            ArrayList<Integer> arrayList=new ArrayList<>();
            arrayList.add(10);
            arrayList.add(12);
            arrayList.add(23);
            arrayList.add(34);
            arrayList.add(45);
            arrayList.add(54);
            System.out.println(arrayList);

            List<Integer>list=arrayList.subList(1,3); //左闭右开 获取1,2下标的元素并进行打印
            System.out.println(list);

            list.set(0,99); //初始下标改成99
            System.out.println(list);
            System.out.println("=====");
            System.out.println(arrayList);

            for (int i = 0; i < arrayList.size(); i++) {
                System.out.print(arrayList.get(i)+" ");
            }
            System.out.println();
            System.out.println("=======");

            for (Integer x:arrayList){
                System.out.println(x+" ");
            }
            System.out.println();
            System.out.println("======");
            Iterator<Integer> it= arrayList.iterator();
            while (it.hasNext()){
                System.out.println(it.next()+" ");
            }
            System.out.println();
            System.out.println("======");

            ListIterator<Integer> it2= arrayList.listIterator();
            while (it2.hasNext()){
                System.out.print(it.next()+" ");
            }
            System.out.println("=====");


        }
        public static void main2(String[] args) {
            ArrayList<Integer> arrayList=new ArrayList<>();
            arrayList.add(10);
            arrayList.add(12);
            System.out.println(arrayList);
            arrayList.remove(1);//删除1下标
            // arrayList.remove(new Integer(10));//删除元素
            arrayList.remove(Integer.valueOf(10)); //删除1下标
            System.out.println(arrayList);

//        ArrayList<Integer> arrayList2=new ArrayList<>(5);

            ArrayList<Integer> arrayList3=new ArrayList<>();
            arrayList3.addAll(arrayList);
            System.out.println(arrayList3);
        }
    }

